<template>
  <div class="wrap">
    <div class="content flex_between">
      <div class="left">
        <div class="top gray_f f14">
          <!-- 帮助中心首页 > 行业法规 > 详情 -->
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>行业法规</el-breadcrumb-item>
            <el-breadcrumb-item>详情</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="title f20">
          <b>{{ dataInfo.title }}</b>
        </div>
        <div class="gray_f f12 date">{{ dataInfo.name }} {{ dataInfo.createTime }} 发布</div>
        <div class="f14 mt20"><b>详细内容：</b></div>
         <div class="concat f14" style="text-indent: 20px;" v-html="dataInfo.content"></div>
        <template v-if="type=='buy'">
          <div class="f14 mt20"><b>联系人及联系方式：</b></div>
          <div class="concat flex_start f14">
            <img class="icon" src="../../../public/img/lianxi1.png" />
            {{ dataInfo.company }}
          </div>
          <div class="concat flex_start f14">
            <img class="icon" src="../../../public/img/lianxi2.png" />
            {{ dataInfo.name }}
          </div>
          <div class="concat flex_start f14">
            <img class="icon" src="../../../public/img/lianxi3.png" />
            {{ dataInfo.phone }}
          </div>
        </template>

      </div>
      <div class="right">
        <div class="toptit flex_start f18">
          <img class="icon" src="../../../public/img/msg1.png" />
          <b>更多平台规则</b>
        </div>
        <div class="cardlist">
          <div class="card pointer" v-for="(item, i) in dataList" :key="i" @click="itemOnClick(item)">
            <div class="flex_between ">
              <div class="flex_item f16 overell">{{ item.title }}</div>
              <div class="f12 gray_f">{{ item.createTime }}</div>
            </div>
            <div class="f14 deepgray_f text moreline">{{ item.content }}</div>
            <div class="main_co">
              <div class="flex_start f14">
                查看
                <i class="el-icon-arrow-right main_co"></i>
              </div>
            </div>
          </div>
          <div class="pub_center pagenum">
            <el-pagination
              @size-change="sizeChangeHandle"
              @current-change="currentChangeHandle"
              :current-page="pageNo"
              :page-sizes="[10, 20, 50, 100]"
              :page-size="pageSize"
              :total="total"
              layout="total, prev, pager, next"
            ></el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getList, getDetail } from '@/api/module/infobuy';
import { getList as getInfoList } from '@/api/module/info';
import { getDetail as getInfoDetail } from '@/api/module/info';

export default {
  data() {
    return {
      dataList: [],
      pageNo: 1,
      pageSize: 3,
      total: 0,
      detailId: '',
      dataInfo: {},
      type: ''
    };
  },
  created() {
    this.detailId = this.$route.params.detailId;
    this.type = this.$route.params.type;
    this.init();
    this.refreshList();
  },
  methods: {
    itemOnClick(item) {
      this.detailId = item.id;
      this.init();
    },
    init() {
      if (this.type == 'buy') {
        getDetail(this.detailId).then(({ data }) => {
          console.log(data);
          if (data && data.success) {
            this.dataInfo = data.data;
          }
        });
      } else {
        getInfoDetail(this.detailId).then(({ data }) => {
          console.log(data);
          if (data && data.success) {
            this.dataInfo = data.data;
          }
        });
      }
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageNo = 1;
      this.refreshList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageNo = val;
      this.refreshList();
    },

    refreshList(pageNo = 1) {
      let parmas = {
        descs: 'create_time'
      };
      if (this.type == 'buy') {
        getList(pageNo, this.pageSize, parmas).then(({ data }) => {
          if (data && data.success) {
            this.dataList = data.data.records;
            this.total = data.data.total;
          }
        });
      } else {
        getInfoList(pageNo, this.pageSize, parmas).then(({ data }) => {
          if (data && data.success) {
            this.dataList = data.data.records;
            this.total = data.data.total;
          }
        });
      }
    }
  }
};
</script>

<style scoped lang="scss">
.wrap {
  height: 100%;
  overflow: auto;
}
.content {
  align-items: flex-start;
  width: 1200px;
  margin: 0 auto;
}
.left {
  width: 776px;
  padding: 30px 0;
  .top {
    // padding: 30px 0;
  }
  .title {
    margin-bottom: 16px;
    margin-top: 30px;
  }
  .concat {
    width: 388px;
    background: #f5f7fa;
    opacity: 1;
    border-radius: 4px;
    margin-top: 20px;
    padding:16px;
    .icon {
      width: 24px;
      box-shadow: 24px;
      margin-right: 8px;
    }
  }
  .mt20 {
    margin-top: 20px;
  }
}
.right {
  width: 344px;
  padding: 30px 0;
  .toptit {
    margin-bottom: 20px;
    .icon {
      width: 24px;
      height: 24px;
      margin-right: 6px;
    }
  }
  .card {
    background: #ffffff;
    border: 1px solid #dce1e6;
    border-radius: 4px;
    margin: 10px 0;
    box-sizing: border-box;
    padding: 32px;
    .text {
      margin: 20px 0 10px;
    }
  }
  .pagenum {
    background: #ffffff;
    border: 1px solid #dce1e6;
    border-radius: 4px;
    margin: 10px 0;
    box-sizing: border-box;
    padding: 0 32px;
  }
}
</style>
